
package cn.batch.daemon.util;

import cn.batch.daemon.taskEnum.CardStatus;

/**
 * @author xihn
 * 解析人行征信报告中的贷记卡信息字符，获得贷记卡(信用卡状态)
 */
public class AnalysisCreditCard {

	private static String splitPoint = "。";
	private static String splitComma = "，";
	
	/**
	 * 解析人行征信报告中的贷记卡信息字符，获得贷记卡(信用卡状态),授信额度
	 * @param s
	 * @return
	 * @throws ParseException 
	 */
	public static String getCreditCardStatus(String s){
		String cardStatus = "";
		CardStatus[] cardS = CardStatus.ALL;
		String [] sForPoint = s.split(splitPoint);
		String cardInfo = sForPoint[0];		
		for (int i = 0; i < cardS.length; i++) {
			CardStatus cs = cardS[i];
			if(cardInfo.endsWith(cs.getDisplayText())){
				cardStatus = cs.getValue();
			}
		}	
		
		if(cardStatus.equals(""))
			cardStatus = CardStatus.ZC.getValue();
		return cardStatus;
	}
	
	/**
	 * 解析人行征信报告中的贷记卡信息字符，授信额度
	 * @param s
	 * @return
	 * @throws ParseException 
	 */
	public static String getCreditCardLimit(String s){
		String creditL = "";
		String [] sForPoint = s.split(splitPoint);
		String cardInfo = sForPoint[0];		
		String[] creditLimit = cardInfo.split(splitComma);
		if(creditLimit.length>3){
			creditL = creditLimit[2].substring(4).replace("折合人民币", "").replace("元", "");
		}
		return creditL;
	}
}
